' permette di inserire più di un part
   Private Function MakeMultipleInsert(ByVal nNbr As Integer, sName As String) As Boolean
      Dim InsertColor As Color3d = New Color3d(89, 210, 210)
      CompoColor(InsertColor, m_MainWindow.GetIniFile())

      ' Imposto il contesto corrente
      EgtSetCurrentContext(DrawScene.GetCtx())
      Dim Pz As Integer = -1
      Dim NxtPz As Integer = -1

      ' Cancello layer regioni per selezione buchi
      Pz = EgtGetFirstGroupInGroup(GDB_ID.ROOT)

      While Pz <> -1
         ' imposto il contesto corrente
         EgtSetCurrentContext(DrawScene.GetCtx())
         ' salvo il file temporaneo per studio delle alzatine
         EgtSaveFile("c:\EgtData\OmagCUT\Temp\TempAlzatine.nge", NGE.CMPTEXT)
         ' cerco un altro pezzo nell'elenco
         NxtPz = EgtGetNextPart(Pz)

         Dim SelectRegion As Integer = EgtGetFirstNameInGroup(Pz, "SelectRegion")
         EgtErase(SelectRegion)
         ' Cancello layer etichette, quotatura,ausiliario e box
         EgtErase(EgtGetFirstNameInGroup(Pz, "LayAux"))
         EgtErase(EgtGetFirstNameInGroup(Pz, "Etichette"))
         EgtErase(EgtGetFirstNameInGroup(Pz, "Quotature"))
         EgtErase(EgtGetFirstNameInGroup(Pz, "Box"))

         ' Cancello layer etichette dei componenti interni (buchi)
         Dim nHLId As Integer = EgtGetFirstNameInGroup(Pz, "HoleLabels")
         While nHLId <> GDB_ID.NULL
            EgtErase(nHLId)
            nHLId = EgtGetFirstNameInGroup(Pz, "HoleLabels")
         End While

         ' Attivo visualizzazione misura
         Dim nRegLayId As Integer = EgtGetFirstNameInGroup(Pz, NAME_REGION)
         Dim nId As Integer = EgtGetFirstInGroup(nRegLayId)
         While nId <> GDB_ID.NULL
            If EgtGetType(nId) = GDB_TY.EXT_TEXT Then
               EgtSetStatus(nId, GDB_ST.ON_)
            End If
            nId = EgtGetNext(nId)
         End While

         ' Calcolo dimensione ingombro Pezzo tramite OutLoop
         Dim nOutLoopLayer = EgtGetFirstNameInGroup(Pz, NAME_OUTLOOP)
         Dim b3Part As New BBox3d
         EgtGetBBoxGlob(nOutLoopLayer, GDB_BB.STANDARD, b3Part)
         ' Muovo la regione in Z per evitare problemi in visualizzazione
         EgtMove(nRegLayId, New Vector3d(0, 0, DELTAZ_REG), GDB_RT.GLOB)

         ' Se pezzo con dati TRF
         If m_bTrfData Then
            ' Nome da dati Trf
            Dim nTextId = EgtGetFirstInGroup(nRegLayId)
            While nTextId <> GDB_ID.NULL
               If EgtGetType(nTextId) = GDB_TY.EXT_TEXT Then
                  Dim sText As String = m_TrfOrderCode & "-" & m_TrfOrderDesc
                  Dim sText2 As String = m_TrfMatCode & "-" & m_TrfSurfCode
                  Dim sText3 As String = LenToString(b3Part.DimX(), 0) & " x " & LenToString(b3Part.DimY(), 0) & " x " & LenToString(m_TrfThickness, 0)
                  Dim dRatio As Double = Math.Max(b3Part.DimX(), b3Part.DimY()) / Math.Min(b3Part.DimX(), b3Part.DimY())
                  If dRatio < 5 Then
                     sText = sText & "<br/>" & sText2 & "<br/>" & sText3
                  Else
                     sText = sText & "  " & sText2 & "  " & sText3
                  End If
                  EgtModifyText(nTextId, sText)
                  Dim ptCen As Point3d
                  EgtCenterPoint(nTextId, ptCen)
                  Dim b3Text As New BBox3d
                  EgtGetBBoxGlob(nTextId, GDB_BB.STANDARD, b3Text)
                  Dim dCoeff As Double = Math.Min(b3Part.DimX() / b3Text.DimX(), b3Part.DimY() / b3Text.DimY()) / 1.25
                  If dCoeff < 1 Then EgtScale(nTextId, New Frame3d(ptCen), dCoeff, dCoeff, dCoeff)
                  Exit While
               End If
               nTextId = EgtGetNext(nTextId)
            End While
            ' Info di pezzo da dati Trf
            EgtSetInfo(Pz, "OC", m_TrfOrderCode)
            EgtSetInfo(Pz, "OD", m_TrfOrderDesc)
            EgtSetInfo(Pz, "PC", m_TrfPartCode)
            EgtSetInfo(Pz, "MT", m_TrfMatCode)
            EgtSetInfo(Pz, "SRF", m_TrfSurfCode)
            EgtSetInfo(Pz, "L", DoubleToString(b3Part.DimX(), 1))
            EgtSetInfo(Pz, "W", DoubleToString(b3Part.DimY(), 1))
            EgtSetInfo(Pz, "T", m_TrfThickness)
            EgtSetInfo(Pz, "V1", DoubleToString(b3Part.DimX(), 1))
            EgtSetInfo(Pz, "V2", DoubleToString(b3Part.DimY(), 1))
            ' Se altrimenti pezzo con dati Csv
         ElseIf m_bCsvData Then
            ' Nome del pezzo
            EgtSetName(Pz, m_sCsvName)
            ' Dati Csv
            EgtSetInfo(Pz, INFO_CSV_PART, m_sCsvName)
            EgtSetInfo(Pz, INFO_CSV_ORD, m_sCsvOrder)
            EgtSetInfo(Pz, INFO_CSV_DIST, m_sCsvList)
            EgtSetInfo(Pz, INFO_CSV_MAT, m_MainWindow.m_CurrentMachine.CurrMat.sName)
            EgtSetInfo(Pz, INFO_CSV_V1, DoubleToString(b3Part.DimX(), 1))
            EgtSetInfo(Pz, INFO_CSV_V2, DoubleToString(b3Part.DimY(), 1))
            ' Se definito nome lo inserisco nel testo
            If Not String.IsNullOrWhiteSpace(m_sCsvName) Then
               Dim nTextId = EgtGetFirstInGroup(nRegLayId)
               While nTextId <> GDB_ID.NULL
                  If EgtGetType(nTextId) = GDB_TY.EXT_TEXT Then
                     Dim sText As String = String.Empty
                     EgtTextGetContent(nTextId, sText)
                     Dim sNewText = m_sCsvName & "<br/>" & sText
                     EgtModifyText(nTextId, sNewText)
                     Exit While
                  End If
                  nTextId = EgtGetNext(nTextId)
               End While
            End If
            ' Altrimenti pezzo con dati normali
         Else
            ' Se definito nome lo inserisco nel testo
            If Not String.IsNullOrWhiteSpace(sName) Then
               Dim nTextId = EgtGetFirstInGroup(nRegLayId)
               While nTextId <> GDB_ID.NULL
                  If EgtGetType(nTextId) = GDB_TY.EXT_TEXT Then
                     Dim sText As String = String.Empty
                     EgtTextGetContent(nTextId, sText)
                     Dim sNewText = sName & "<br/>" & sText
                     EgtModifyText(nTextId, sNewText)
                     Exit While
                  End If
                  nTextId = EgtGetNext(nTextId)
               End While
            End If
         End If
         ' Eventuale testo per indicare il sopra (solo nel caso di rettangolo)
         If TopChBx.IsVisible() And TopChBx.IsChecked() Then
            Utility.AddTopToPartRegion(nRegLayId)
         End If
         ' Scrivo testi per nesting
         SideAngle.WriteSideAngleForNest(DrawScene.GetCtx())
         ' Imposto colore testi
         Utility.SetTextColor(nRegLayId)
         ' Imposto il colore del pezzo inserito nel progetto
         Dim nPartInRegion As Integer = EgtGetFirstInGroup(nRegLayId)
         EgtSetColor(nPartInRegion, InsertColor)

         ' Esporto il pezzo in un file temporaneo
         Dim sTmpFile As String = m_MainWindow.GetTempDir() & "\FlatPartCompo.Nge"
         If Not EgtSaveObjToFile(Pz, sTmpFile, NGE.BIN) Then
            Return False
         End If

         ' Passo al contesto principale
         EgtSetCurrentContext(m_MainWindow.m_CurrentProjectPageUC.CurrentProjectScene.GetCtx())
         ' Recupero flag per inserimento diretto in grezzo (altrimenti in parcheggio)
         Dim bDirect As Boolean = (GetPrivateProfileInt(S_NEST, K_DIRECT, 0, m_MainWindow.GetIniFile()) <> 0)
         ' Elimino eventuali precedenti pezzi vuoti
         EgtEraseEmptyParts()
         ' Area dei nuovi pezzi
         Dim dNewArea As Double = 0
         ' Se esiste il file del pezzo
         If My.Computer.FileSystem.FileExists(sTmpFile) Then
            ' eseguo inserimento
            For i As Integer = 1 To nNbr
               ' Inserisco il pezzo
               EgtInsertFile(sTmpFile)
               ' Ne recupero l'Id
               Dim nId2 As Integer = EgtGetLastPart()
               ' Aggiusto per lavorazioni
               EgtAdjustFlatPart(nId2)
               ' Se dati Trf assegno nome univoco
               If m_bTrfData Then EgtSetInfo(nId2, "CsvPart", m_TrfOrderCode & "-" & nId2.ToString())
               ' Aggiorno l'area dei nuovi pezzi
               dNewArea += GeomCalc.GetPartArea(nId2)
               ' Inserisco in parcheggio
               m_MainWindow.m_CadCutPageUC.m_NestPage.StoreOnePart(nId2, True)

               ' ------------------------ AGGIUNGO PEZZO NEL VEINMATCH ----------------------------------
               ' verifico che il pezzo sia un Piano Cucina o un Piano Bagno o un'Aletta
               Dim sCMP As String = String.Empty
               EgtGetInfo(nId2, "CMP", sCMP)
               If sCMP.StartsWith("PCucina") Or sCMP.StartsWith("PBagno") Or sCMP.StartsWith("AlzFront") Then
                  ' Aggiungo riferimento e lo inserisco in VeinMatching
                  VeinMatching.SetRefOnPart(nId2)
                  VeinMatching.AddPartFromDraw(nId2)
                  ' Se richiesto posizionamento diretto, lo eseguo
                  If bDirect Then
                     If m_MainWindow.m_CadCutPageUC.m_NestPage.InsertOnePart(nId2) Then
                        ' Eventuale notifica al VeinMatching
                        VeinMatching.OnInsertPartInRaw(nId2)
                     End If
                  End If
               End If
               ' ------------------------ AGGIUNGO PEZZO NEL VEINMATCH ----------------------------------

            Next
            ' Cancello il file
            My.Computer.FileSystem.DeleteFile(sTmpFile)
         End If
         ' Aggiorno Aree totale
         m_MainWindow.m_CurrentProjectPageUC.UpdateTotalArea(dNewArea)
         ' passo al pezzo successivo
         Pz = NxtPz
      End While
      ' Aggiorno Aree da lavorare dei pezzi
      m_MainWindow.m_CurrentProjectPageUC.UpdateToProduceArea()
      m_MainWindow.m_CurrentProjectPageUC.ShowAreas()
      ' Aggiorno ambiente principale
      EgtZoom(ZM.ALL)
      Return True
   End Function